#include "stm32f10x.h"                  // Device header
#include "OLED.h"

char *on_text(int index) {
	if (index == 0) return "\0";
	if (index == 1) return "黄";
	if (index == 2) return "黄梓";
	if (index == 3) return "黄梓杭";
	return "";
}

char *on_lspd(int index) {
    if (index == 0) return "\0";
    if (index == 1) return "** - **";
    if (index >= 2 && index <= 4) return "-- - --";
    if (index == 5) return "** - **";
    if (index >= 6 && index <= 8) return "-- - --";
    if (index == 9) return "** - **";
    if (index >= 10 && index <= 12) return "-- - --";
    if (index == 13) return "** - **";
    if (index >= 14 && index <= 16) return "-- - --";
    if (index == 17) return "** - **";
    if (index >= 18 && index <= 20) return "-- - --";
    if (index == 21) return "** - **";
    if (index >= 22 && index <= 24) return "-- - --";
    if (index == 25) return "** - **";
    if (index >= 26 && index <= 28) return "-- - --";
    if (index == 29) return "** - **";
    if (index >= 30 && index <= 32) return "-- - --";
    if (index == 33) return "** - **";
    if (index >= 34 && index <= 36) return "-- - --";

    if (index == 37) return "** - --";
    if (index >= 38 && index <= 40) return "-- - --";
    if (index == 41) return "** - --";
    if (index >= 42 && index <= 44) return "-- - --";
    if (index == 45) return "** - --";

    if (index >= 46 && index <= 48) return "-- - --";
    if (index == 49) return "-- - **";
    if (index >= 50 && index <= 52) return "-- - --";
    if (index == 53) return "-- - **";
    if (index >= 54 && index <= 56) return "-- - --";
    if (index == 57) return "-- - **";

    if (index >= 58 && index <= 60) return "-- - --";
    if (index == 61) return "** - --";
    if (index >= 62 && index <= 64) return "-- - --";
    if (index == 65) return "** - --";
    if (index >= 66 && index <= 68) return "-- - --";
    if (index == 69) return "** - --";

    if (index >= 70 && index <= 72) return "-- - --";
    if (index == 73) return "-- - **";
    if (index >= 74 && index <= 76) return "-- - --";
    if (index == 77) return "-- - **";
    if (index >= 78 && index <= 80) return "-- - --";
    if (index == 81) return "-- - **";

    if (index >= 82 && index <= 84) return "-- - --";
    if (index == 85) return "** - --";
    if (index >= 86 && index <= 88) return "-- - --";
    if (index == 89) return "** - --";
    if (index >= 90 && index <= 92) return "-- - --";
    if (index == 93) return "** - --";

    if (index >= 94 && index <= 96) return "-- - --";
    if (index == 97) return "-- - **";
    if (index >= 98 && index <= 100) return "-- - --";
    if (index == 101) return "-- - **";
    if (index >= 102 && index <= 104) return "-- - --";
    if (index == 105) return "-- - **";
}

int main(void)
{
	
	OLED_Init();
    int one_x_is_end = 0;
    int one_x = 0;
	int count = 0;
	int txt_index = 0;
    int lspd_index = 0;
    while (1) {
        if (one_x_is_end && one_x - 1 <= 0) {
            one_x_is_end = 0;
        } else if (one_x + 1 >= 60) {
            one_x_is_end = 1;
        }
        OLED_Clear();
		OLED_ShowString(34,0, on_lspd(lspd_index),OLED_8X16);
        OLED_ShowChinese(one_x, 24, "东莞理工");
        OLED_ShowChinese(38, 50, on_text(txt_index));
        OLED_Update();
        one_x_is_end ? one_x-- : one_x++;
        lspd_index = (lspd_index + 1) % 102;
		if (count % 12 == 0) {
            txt_index = (txt_index + 1) % 4;
			count = 0;
		}
		count++;
    }
}
